package cn.stylefeng.guns.modular.business.frequency.ordersub.mapper;

import cn.stylefeng.guns.modular.business.frequency.finance.model.result.PkgFinance;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.param.OrderDTO;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.result.OrderProgressVO;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.result.OrderSubExport;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.result.PkgOrderSub;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.result.PkgOrderSubBase;
import cn.stylefeng.guns.modular.business.frequency.statistics.IndexDataVO;
import cn.stylefeng.guns.modular.business.frequency.statistics.PkgDailyDataStatistics;
import cn.stylefeng.guns.modular.business.frequency.statistics.PkgMonthDataStatistics;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.stylefeng.guns.modular.business.frequency.ordersub.entity.OrderSub;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;


import java.math.BigDecimal;
import java.util.List;

/**
 * 子订单 Mapper 接口
 *
 * @author yujie
 * @date 2023/05/09 17:16
 */
public interface OrderSubMapper extends BaseMapper<OrderSub> {

    String getLastOrderNo(@Param("tenantId") Long tenantId);

    int getStatusById(@Param("id") Long id);

    Page<PkgOrderSub> getOrderListPage(@Param("page") Page<Object> defaultPage,@Param("orderDTO") OrderDTO orderDTO);

    PkgOrderSub getOrderListSummary(@Param("orderDTO") OrderDTO orderDTO);

    /**获取订单详情*/
    PkgOrderSub getOrderDetail(@Param("id") Long id);

    OrderProgressVO getProgressStatusById(@Param("id") String id);

    List<PkgOrderSubBase> getOrderInfos(List<Long> orderIds);

    void cancelById(@Param("id") String id);

    List<OrderSubExport> getOrderExportList( @Param("orderDTO") OrderDTO orderDTO);

    void updateVinById(@Param("vin") String vin, @Param("orderId") Long orderId);

    /** 修改订单状态 */
    void updateStatusById(@Param("orderId") Long orderId, @Param("status") Integer status,
                          @Param("originStatus") Integer originStatus);

    int distinctCountConsigneePhone(@Param("orderIds") List<Long> orderIds);

    String getOrderDestinationCode(@Param("id") Long id);

    String getOrderStartCode(@Param("orderId") Long orderId);

    //统计相关
    PkgDailyDataStatistics getDailyData(@Param("month") String month);

    List<PkgMonthDataStatistics> getMonthGrossData(@Param("month") String month);

    PkgFinance getMonthCollectionPaymentData(@Param("month") String month);

    List<PkgMonthDataStatistics> getMonthBusinessData(@Param("month") String month);

    List<PkgMonthDataStatistics> getMonthSiteOrderCount(@Param("month") String month);

    List<Integer> getMonthSitePickCount(@Param("month") String month);

    List<Integer> getMonthSiteTransportCount(@Param("month") String month);

    List<Integer> getMonthSiteDeliveryCount(@Param("month") String month);

    Long getOrderCount(@Param("orderDTO") OrderDTO orderDTO);

    /** 在途数量 */
    Long countLogistics(@Param("orderDTO") OrderDTO orderDTO,@Param("tenantId") Long tenantId);

    /** 客户下单月度排名 */
    List<PkgMonthDataStatistics> getLinkmanOrderRank(@Param("month") String month);

    /** 客户承运月度排名 */
    List<PkgMonthDataStatistics> getLinkmanTransportRank(@Param("month") String month);

    List<Integer> getMonthSiteSignCount(@Param("month") String month);

    /** 订单ID查询订单状态 */
    List<Integer> getOrderStatusByOrderIds(@Param("orderIds") List<Long> orderIds);


    BigDecimal getTotalDeliveryFee(@Param("orderIds") List<Long> orderIds);


    PkgOrderSub getSubOrderDetail(@Param("id") Long id);


    IndexDataVO getOrderAllCount(@Param("tenantId") Long tenantId);

    List<String> selectStartCodeListByUserId(@Param("sysLoginUserId") Long sysLoginUserId);
}